# -*- coding: utf-8 -*-

from django.conf import settings
from django.contrib import admin
from website.models import *

#from easy_thumbnails.files import get_thumbnailer
#
#class AdminThumbnailMixin(object):
#    thumbnail_options = {'size': (60, 60)}
#    thumbnail_image_field_name = 'image'
#    thumbnail_alt_field_name = None
#
#    def _thumb(self, image, options={'size': (60, 60)}, alt=None):
#        media = getattr(settings, 'THUMBNAIL_MEDIA_URL', settings.MEDIA_URL)
#        attrs = []
#        src = "%s%s" % (media, get_thumbnailer(image).get_thumbnail(options))
#
#        if alt is not None: attrs.append('alt="%s"' % alt)
#
#        return mark_safe('<img src="%s" %s />' % (src, " ".join(attrs)))
#
#    def thumbnail(self, obj):
#        kwargs = {'options': self.thumbnail_options}
#        if self.thumbnail_alt_field_name:
#            kwargs['alt'] = getattr(obj, self.thumbnail_alt_field_name)
#        return self._thumb(getattr(obj, self.thumbnail_image_field_name), **kwargs)
#    thumbnail.allow_tags = True
#    thumbnail.short_description = _('Thumbnail')
#
############# inline ###############
class ImageEventInline(admin.TabularInline):
    model = ImageEvent
    extra = 1

class ImageLieuInline(admin.TabularInline):
    model = ImageLieu
    extra = 1

class Score_LieuInline(admin.TabularInline):
    model = Score_Lieu
    extra = 1

class Score_EventInline(admin.TabularInline):
    model = Score_Event
    extra = 1



###########################$

class UserAdmin(admin.ModelAdmin):
    list_display = ("nom","email")
    inlines = [Score_LieuInline,Score_LieuInline]
admin.site.register(User,UserAdmin)

class Type_UserAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Type_User,Type_UserAdmin)

class Type_VisiteurAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Type_Visiteur,Type_VisiteurAdmin)

class LieuAdmin(admin.ModelAdmin):
    list_display = ("nom","ville","propose_par")
    inlines = [ImageLieuInline,Score_LieuInline]
admin.site.register(Lieu,LieuAdmin)

class Type_LieuAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Type_Lieu,Type_LieuAdmin)

class EventAdmin(admin.ModelAdmin):
    list_display = ("nom","lieu")
    inlines = [ImageEventInline,]
admin.site.register(Event,EventAdmin)


class Type_EventAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Type_Event,Type_EventAdmin)

class RegionAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Region,RegionAdmin)

class DepartementAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Departement,DepartementAdmin)

class VilleAdmin(admin.ModelAdmin):
    list_display = ("nom",)
admin.site.register(Ville,VilleAdmin)

#class Score_EventAdmin(admin.ModelAdmin):
#    list_display = ("score","event","user")
#admin.site.register(Score_Event,Score_EventAdmin)

#class Score_LieuAdmin(admin.ModelAdmin):
#    list_display = ("score","event","user")
#admin.site.register(Score_Lieu)

#class ImageLieuAdmin(admin.ModelAdmin):
#    list_display = ("path_image",)
#admin.site.register(ImageLieu,ImageLieuAdmin)

#class ImageEventAdmin(admin.ModelAdmin):
#    list_display = ("path_image",)
#admin.site.register(ImageEvent,ImageEventAdmin)


